//
//  LocalizeMeViewController.m
//  Localizationn
//
//  Created by wp w on 12-6-18.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "LocalizeMeViewController.h"
@implementation LocalizeMeViewController
@synthesize localeLabel;
@synthesize label1;
@synthesize label2;
@synthesize label3;
@synthesize label4;
@synthesize label5;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //一般本地化包含两部分，一个时区域格式（如货币、当地时间等）、一个时语言。在该示例中title为区域格式。下边的label为语言
    NSLocale *locale = [NSLocale currentLocale];
    NSString *displayNameString = [locale
                                   displayNameForKey:NSLocaleIdentifier
                                   value:[locale localeIdentifier]];
    localeLabel.text = displayNameString;
    
    //从默认语言文件“Localizable.strings”中读取Key的值 
    //假如在文件中未找到key对应的值，则返回key
    label1.text = NSLocalizedString(@"One", @"The number 1");
    label2.text = NSLocalizedString(@"贰", @"The number 2");
    label3.text = NSLocalizedString(@"Three", @"The number 3");
    //从自定义语言文件中读取Key的值
    label4.text = NSLocalizedStringFromTable(@"Four", @"My", @"The number 4");
    label5.text = NSLocalizedStringFromTable(@"Five", @"My", @"The number 5");
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
